package edu.nf.vac.admin.controller;

import edu.nf.vac.admin.vo.ResultVO;
import edu.nf.vac.vaccination.dto.NeedleNumDTO;
import edu.nf.vac.vaccination.dto.NeedleNumPageDTO;
import edu.nf.vac.vaccination.inf.NeedleNumService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author : QYM
 * @create 2022/4/6
 */
@RestController
public class NeedleNumController extends BaseController{
    @DubboReference(interfaceClass = NeedleNumService.class,version = "1.0.0")
    private NeedleNumService needleNumService;

    /**
     * 创建针次，包括该针次的接种时段以及不同时段可接种的疫苗
     * @param dto
     */
    @PostMapping("/needlenum/save")
    public ResultVO addNeedleNum(NeedleNumDTO dto){
        needleNumService.addNeedleNum(dto);
        return success();
    }

    /**
     * 更新针次与时段信息
     * @param dto
     */
    @PostMapping("/periods/update")
    public ResultVO updatePeriods(NeedleNumDTO dto){
        needleNumService.updateNeedleNum(dto);
        return success();
    }

    /**
     * 针次列表信息查询
     * @param dto 查询条件
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/needlenum/list")
    public ResultVO<List<NeedleNumDTO>> listNeedleNum(NeedleNumDTO dto, int page, int limit){
        NeedleNumPageDTO pageDTO = needleNumService.listNeedleNum(dto, page, limit);
        return pageResult(pageDTO.getTotal(),pageDTO.getList());
    }
}
